package top.kaoshanji.p2ch10b;

import java.util.Arrays;

/**
 * 代码清单-p2ch10b-240页c：Processor接口的实现类
 * author kaoshanji
 * ^_^
 * create time 2025/3/10 19:21
 */
interface StringProcessor extends Processor {

    @Override
    Object process(Object input);

    String S = "If she weighs the same as a duck, she's made of wood";

    static void main(String[] args) {

        Applicator.apply(new Upcase(), S);
        Applicator.apply(new Downcase(), S);
        Applicator.apply(new Splitter(), S);

    }
}

class Upcase implements StringProcessor {

    @Override
    public String process(Object input) {
        return ((String)input).toUpperCase();
    }
}

class Downcase implements StringProcessor {

    @Override
    public String process(Object input) {
        return ((String)input).toLowerCase();
    }
}

class Splitter implements StringProcessor {

    @Override
    public String process(Object input) {
        return Arrays.toString(((String)input).split(" "));
    }
}
